// 风险等级相关
export const getRiskLevelText = (level) => {
  const levels = {
    1: '低风险',
    2: '中低风险',
    3: '中等风险',
    4: '中高风险',
    5: '高风险'
  };
  return levels[level] || '未知';
};

export const getRiskTagType = (level) => {
  const types = {
    1: 'success',
    2: 'info',
    3: 'warning',
    4: 'danger',
    5: 'danger'
  };
  return types[level] || 'info';
};

// 订单状态相关
export const getOrderStatusText = (status) => {
  const statusMap = {
    1: '持有中',
    2: '已到期',
    3: '已赎回',
    4: '处理中'
  };
  return statusMap[status] || '未知';
};

export const getOrderStatusType = (status) => {
  const typeMap = {
    1: 'success',
    2: 'info',
    3: 'warning',
    4: 'info'
  };
  return typeMap[status] || 'info';
};

// 产品状态相关
export const getStatusText = (status) => {
  const statusMap = {
    1: '在售',
    2: '暂停销售',
    3: '售罄',
    4: '已下线'
  };
  return statusMap[status] || '未知';
};

export const getStatusTagType = (status) => {
  const typeMap = {
    1: 'success',
    2: 'warning',
    3: 'info',
    4: 'danger'
  };
  return typeMap[status] || 'info';
};

// 工具函数
export const formatAmount = (amount, showSign = false) => {
  if (amount === undefined || amount === null) return showSign ? '+0.00' : '0.00';
  const value = parseFloat(amount);
  const formatted = Math.abs(value).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
  if (showSign) {
    return value >= 0 ? `+${formatted}` : `-${formatted}`;
  }
  return formatted;
};

export const formatRate = (rate) => {
  if (rate === undefined || rate === null) return '0.00';
  return parseFloat(rate).toFixed(2);
};

export const formatDate = (dateTime) => {
  if (!dateTime) return '-';
  const date = new Date(dateTime);
  return date.toLocaleDateString('zh-CN');
};
